package com.gec.system.controller;

import com.gec.system.config.VodConfig;
import com.gec.system.service.SysMovieService;
import com.gec.system.system.SysMovie;
import com.gec.system.util.Result;
import com.gec.system.utils.OssTemplate;
import com.gec.system.utils.VodTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RequestMapping(value = "/admin/system/upload")
@RestController

@CrossOrigin //  处理 跨域问题
public class UploadController {
    private static final Logger log = LoggerFactory.getLogger(UploadController.class);
    @Autowired
    private OssTemplate ossTemplate;

    @Autowired
    private VodTemplate vodTemplate;

    @RequestMapping("video")
    public String uploadVideo(@RequestParam MultipartFile uploadVideo) throws IOException {
        String video = vodTemplate.uploadVideo(uploadVideo.getOriginalFilename(), uploadVideo.getInputStream());
        System.out.println(video);
        return video;

    }
    @RequestMapping("image")
    public String uploadImage(@RequestParam MultipartFile uploadImage ) throws IOException {
        String image = ossTemplate.upload(uploadImage.getOriginalFilename(), uploadImage.getInputStream());
        return "https://"+image;

    }

}
